import redis
import time
from application import app

class RedisBase:
    def __init__(self):
        pool = redis.ConnectionPool(host = app.config["REDISHOST"],port = 6379,db = 1,max_connections=20,decode_responses = True)
        self.conn = redis.Redis(connection_pool=pool)
    def __del__(self):
        self.conn.close()

class RedisExe(RedisBase):
    def setValue(self,key,value):
        self.conn.set(key,value)
    def getValue(self,key = "time"):
        return self.conn.get(key)


if __name__ == "__main__":
    curTime = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
    rdex = RedisExe()
    rdex.setValue(curTime)
